<div class="row"> <small>
  <div class="span3 bs-docs-sidebar "> <*include file="<*$controller*>/location.tpl"*> </div>
  <div class="span9 " >
    <div class="clearfix txtleft" style="background-color:#f8f8f8; padding:10px; margin:10px 0px; text-align:center;">
      <button class="btn btn-primary btn-small" onClick="addit('<*$uid*>','<*$pid*>','<*$keyworld*>')" >充值</button>
      &nbsp;&nbsp;
      <button class="btn btn-primary btn-small" onClick="addyhq('<*$uid*>','<*$pid*>','<*$keyworld*>')" >优惠券</button>
      &nbsp;&nbsp;
      <button class="btn btn-primary btn-small"  onClick="cost('<*$uid*>','<*$keyworld*>','<*$amount.$uid.balance*>','<*$pid*>')" >购买服务</button>
    </div>
    <*if $result|@count neq 0*>
    <table class="table table-condensed table-bordered table-hover span9">
      <tr class="success">
        <td><strong>名称</strong></td>
        <td><strong>类型</strong></td>
        <td><strong>金额(元)</strong></td>
        <td><strong>时间</strong></td>
        <td><strong>来源IP</strong></td>
        <td><strong>说明</strong></td>
        <td><strong>详细</strong></td>
        <td><strong>关联订单</strong></td>
      </tr>
      <*foreach from=$result item=a key =key name=foo*>
      <tr>
        <td class="span1"><*$a.cnname*></td>
        <td class="span1"><*if $a.paytype eq 'cost'*><small>消费</small><*else if $a.paytype eq 'add'*><small>充值</small><*if $a.pid eq 0*>（券）<*else*><small>（现金）</small><*/if*><*/if*></td>
        <td class="span1"><strong><*$a.amount*></strong></td>
        <td class="span2"><*$a.addtime|date_format:'%Y-%m-%d %H:%M:%S'*></td>
        <td class="span1"><*$a.clientip*></td>
        <td class="span1"><*$a.memo*></td>
        <td class="span1"><a  style="cursor:pointer" onClick="detailfun('<*$a.accountid*>','<*$a.cnname*>')" ><i class="icon-list-alt"></i></a></td>
        <td class="span1"><*if $a.orderid*><a href="/<*$controller*>/orderdetail/orderid/<*$a.orderid*>" >关联的订单</a><*else*>&nbsp;<*/if*></td>
      </tr>
      <*/foreach*>
      <tr>
        <td colspan="8"><strong> 总计（元）：<*$amount.$uid.add*> &nbsp; 消费（元）：<*$amount.$uid.cost*> &nbsp;  可用余额（元）：<*$amount.$uid.balance*></strong></td>
      </tr>
    </table>
    <*else*>  
    没有账户操作信息！   
    <*/if*> </div>
  </small> 
  
  <!-- <script type="text/javascript" src="/js/prototype.js"></script>  --> 
  <script type="text/javascript"> 
  
  
 
       function   ajax_post(){ 
	    var groupsid="<*$groups*>"; 
        $.post("/<*$controller*>/groups/",{"jigouid":groupsid},function(data,statusText){ 
			 $("#jigou").append(data); 
        });  
	 } 
	  
	  $("#jigou").change(function(){
           // $("#city option:gt(0)").remove();  //清空所有城市的信息
            //$("#county option:gt(0)").remove();  //清空所有县级的信息
            var id = this.value;
			var schoolid="<*$schoolid*>";  
			  
            $.post("/<*$controller*>/schoollist/",{"id":id,"sid":schoolid},function(data,statusText){
                 $("#school").html('');
                 $("#school").append(data);
            
            });
        });
		
		$("#school").change(function(){
           // $("#city option:gt(0)").remove();  //清空所有城市的信息
            //$("#county option:gt(0)").remove();  //清空所有县级的信息
            var sid = this.value; 
            $.post("/<*$controller*>/classlist/",{"id":sid},function(data,statusText){
				 
                 $("#class1").html('');
                 $("#class1").append(data);
            
            });
        });
		
	
	 window.onload=function(){
	    ajax_post(); 
	 if( '<*$groups*>'+0 != 0 ){ 
	        
			var id = '<*$groups*>'; 
			var sid = '<*$schoolid*>';  
			 
			$.post("/<*$controller*>/schoollist/",{"id":id,"sid":sid},function(data,statusText){
				 $("#school").html('');
				 $("#school").append(data); 
				});
	    } 
          
	 if('<*$schoolid*>'+0 != 0){   
		   var id = '<*$schoolid*>'; 
		   var cid='<*$classid*>';
			$.post("/<*$controller*>/classlist/",{"id":id,"cid":cid},function(data,statusText){ 
				 $("#class1").html('');
				 $("#class1").append(data); 
				}); 
		   
	 }/* */

 } 
	
function detailfun(id,name){
	   window.location='/<*$controller*>/accountdetail/id/'+id+'/name/'+name;   
	   }  		 
		
	  
</script> 
  <script type="text/javascript" src="/js/bootstrap-datetimepicker.min.js"></script> 
  <script type="text/javascript" src="/js/DatePicker/WdatePicker.js" ></script> 
  <script type="text/javascript">

  
	
 function addit(uid,pid,keyworld){
	$(document).ready(function(){
	 //  $(".addnew").click(function(){ // Click to only happen on announce links
		 $("#uid").val(uid);
		 $("#pid").val(pid);
		 $("#keyworld").val(keyworld);
		 $('#myModal').modal('show');
	  // });
	}); 		
}
 

function addyhq(uid,pid,keyworld){
	 
	 $(document).ready(function(){ 
		 $("#suid").val(uid);
		 $("#parent_id").val(pid);
		 $("#key").val(keyworld);
		 $('#myyhq').modal('show');
	  // });
	}); 
}


function checkLoginForm(){
	var ammount=document.getElementById('ammount').value;
	 
	if(ammount=='' || ammount==null){
		alert('需要输入你的充值金额');
		document.getElementById("ammount").focus();
		return false;
	} 
	return true;
}
<!--消费情况的信息-->

function cost(uid,key,canused,pid){
	 
	$(document).ready(function(){  
		 $("#uid_student").val(uid); 
		 $("#uid_parent").val(uid);
		 $("#keycnname").val(key);
		 $("#balance").val(canused);
		 $('#myCost').modal('show'); 
	}); 		
}

function checkForm(){
	// var code_Values = document.getElementsByName("box");
	  
	 var  list = document.getElementsByName("box"); 
     var  typelist='';
	  for( i =0 ; i<list.length; i++ )
  		{  
			if( list[i].checked==true ){
				 var  typelist=i+1;
				 } 
  		}   
	if(typelist=='' || typelist==null){
		alert('请选择你需要购买的服务');
		<!--document.getElementById("ammount").focus();-->
		return false;
	} 
	 
	 var  trueprice = document.getElementById("trueprice").value; 
	 
	if(trueprice=='' || trueprice==null){
		alert('请选择正确的服务信息');
		return false;
		}
	 
	return true;
}
   
	
function aa(code){  
		
		$.ajax({ 
			url:'/<*$controller*>/opyhq', 
			type:'post', //数据发送方式 
			dataType:'html', //接受数据格式 (这里有很多,常用的有html,xml,js,json) 
			data:'code='+$("#code").val(), //要传递的数据 
			error: function(err){ //失败 
			alert('Error loading document'); 
			}, 
			success: function(msg){ //成功 
			   if(msg==0){
				   document.getElementById("error").innerHTML='<p style="color:red">参数错误请检查</p>';
				   document.getElementById("btn").disabled=true;
				   return false;
				 }else if(msg==2){
				    document.getElementById("error").innerHTML='<p style="color:red">该优惠券已经用过了</p>';
					document.getElementById("btn").disabled=true;
				   return false;				 
				 }else if(msg==3){
				    document.getElementById("error").innerHTML='<p style="color:red">该优惠券不可用</p>';
					document.getElementById("btn").disabled=true;
				   return false;				 
				 }
			    if(msg==1){
				   document.getElementById("error").innerHTML='优惠券可用';
				   document.getElementById("btn").disabled=false;
					} 
			    return true;   
	       } 
	  });   
		 
   }  

<!--购买服务 -->
 
    function checks(a){
	//获取所有的被选中的产品
	 var  list = document.getElementsByName("box");  
     var  typelist='';
	 var price=0;
	  for( i =0 ; i<list.length; i++ )
  		{  
			if( list[i].checked==true ){
				var  typelist=i+1; 
				var  price=list[i].value;
				 } 
  		}
	 
	 var discout= $("#discount").val(); 
	 
	 $("#productid").val(a);
	 
	  if(discout!=''){ 
	     trueprice=price*(discout*10/100); 	 
		 }else{ 
		  trueprice=price;  
			 } 
			 
	   var  canuse=$("#balance").val();	 
	   
	   
	   var tmp1=parseFloat(canuse);   
       var tmp2=parseFloat(trueprice); 
	    
	   if(tmp2 >= tmp1){
		    alert('您的余额不足，请重新选择。或者进行充值'); 
		    document.getElementById("submitbtn").disabled=true; 
		    return false;
		  }	   
			 
	 $("#totalprice").val(price); 
	 $("#trueprice").val(trueprice);
	  
	if(typelist=='' || typelist==null){
		alert('请选择你要购买的产品'); 
		return false;
 	}  
	 document.getElementById("submitbtn").disabled=false; 
	  return true;	
	 	 
		} 
 $(function(){ 
  //折扣修改	
  $("#discount").blur(function()
 {   
	  var discout= $("#discount").val(); 
	  
	  var totalprice= $("#totalprice").val(); 
       
	  if(discout!=''){
		trueprice=totalprice*(discout*10/100);
		  }else{
		  trueprice=totalprice; 
			  }
	   var  canuse=$("#balance").val();	 
	   var tmp1=parseFloat(canuse);     
	   
       var tmp2=parseFloat(trueprice); 
	    
	   if(tmp2 >= tmp1){
		    alert('您的余额不足，请重新选择。或者进行充值'); 
		     document.getElementById("submitbtn").disabled=true; 
		    return false;
		  }	 
     $("#trueprice").val(trueprice);  
	 
    } );  
  }); 
   
</script>
  <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form class="form-signin" id="login_form" action="/charges/opadd" method="post" onsubmit="return checkLoginForm();">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">充值</h3>
      </div>
      <div class="row">
        <div class="modal-body span3">
          <label class="control-label pull-left" >学生uid</label>
          <input type="text" class="input-block-level" autocomplete="off" id="uid" name="uid" readonly="readonly" >
          <input type="hidden" class="input-block-level" autocomplete="off" id="keyworld" name="keyworld" readonly="readonly" >
          <label class="control-label pull-left" >家长pid</label>
          <input type="text" class="input-block-level" autocomplete="off" id="pid" name="pid" readonly="readonly" >
          <label class="control-label pull-left" >充值金额</label>
          <input type="text" class="input-block-level" autocomplete="off" placeholder="请输入金额"  id="ammount" name="ammount" >
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" type="submit">保存</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
      </div>
    </form>
  </div>
  <!--优惠券充值 -->
  <div id="myyhq" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form class="form-signin" id="login_form" action="/charges/opaddyhq" method="post" >
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">优惠券充值</h3>
      </div>
      <div class="row">
        <div class="modal-body span3">
          <label class="control-label pull-left" >学生uid</label>
          <input type="text" class="input-block-level" autocomplete="off" id="suid" name="suid" readonly="readonly" >
          <input type="hidden" class="input-block-level" autocomplete="off" id="keyworld" name="keyworld" readonly="readonly" >
          <label class="control-label pull-left" >家长pid</label>
          <input type="text" class="input-block-level" autocomplete="off" id="parent_id" name="parent_id" readonly="readonly" >
          学生名称
          <input type="text" class="input-block-level" autocomplete="off" id="key" name="key" readonly="readonly" >
          <label class="control-label pull-left" >优惠券编号</label>
          <input type="text" class="input-block-level" autocomplete="off" placeholder="请输入金额"  id="code" name="code"  onblur="aa(this.value)">
          <div id="error"></div>
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" id='btn' type="submit">保存</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
      </div>
    </form>
  </div>
  
  <!--消费的弹窗-->
  <div id="myCost" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form class="form-signin" id="login_form" action="/charges/opcost" method="post" onsubmit="return checkForm();">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">购买服务</h3>
      </div>
      <div class="row">
        <div class="modal-body span5">
          <div class="control-group">
            <label class="control-label" >学生uid</label>
            <div class="controls">
              <input type="text" name="uid_student" id="uid_student"  class="input-medium" readonly="readonly"/>
              <input type="hidden" name="uid_parent" id="uid_parent" />
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" >学生名称</label>
            <div class="controls">
              <input type="text" name="keycnname" id="keycnname"  class="input-medium" readonly="readonly"/>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" >余额</label>
            <div class="controls">
              <input type="text" class="input-medium" autocomplete="off" id="balance" name="balance" readonly="readonly" >
            </div>
          </div>
          <div class="control-group">
            <label class="control-label inline" >购买服务</label>
            <div class="controls"> <*foreach from=$productAll item=a key =key name=foo*>
              <label class="radio">
                <input type="radio" name="box" id="<*$a.producttype*>" value="<*$a.productprice*>"  onclick="checks(<*$a.productid*>)">
                <*$a.productname*>(<*$a.productprice*>元) </label>
              <*/foreach*>
              <input  type="hidden" value=""  name="productid" id="productid" />
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" for="生效时间"><strong>生效时间</strong></label>
            <div class="controls" >
              <div class="input-append"  >
                <input type="text" name="effecttime" id="effecttime"  class="input-small" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" language="UTF-8" >
                </input>
                <span class="add-on"> <i data-time-icon="icon-time" class="icon-calendar"> </i> </span> </div>
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" >折扣</label>
            <div class="controls">
              <input type="text" class="input-medium" autocomplete="off" id="discount" name="discount"  placeholder="默认折扣10.0" >
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" >应该收款</label>
            <div class="controls">
              <input type="text" class="input-medium" autocomplete="off" id="totalprice" name="totalprice"  placeholder="应收金额" >
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" >实收金额</label>
            <div class="controls">
              <input type="text" class="input-medium" autocomplete="off" id="trueprice" name="trueprice"  placeholder="实收金额" >
            </div>
          </div>
          <div class="control-group">
            <label class="control-label" >备注</label>
            <div class="controls">
              <input type="text" class="input-medium" autocomplete="off" id="memo" name="memo"  placeholder="备注信息" >
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button class="btn btn-primary" id='submitbtn' type="submit">保存</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
      </div>
    </form>
  </div>
</div>
